package com.hyj.shop.project.article.controller;

import com.hyj.shop.project.article.domain.LikeArticle;
import com.hyj.shop.project.article.service.ArticleService;
import com.hyj.shop.project.utils.controller.BaseController;
import com.hyj.shop.project.utils.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/api")
public class ArticleController extends BaseController {
        @Autowired
       private ArticleService articleService;
        @RequestMapping(value = "/article/readCount/add")
        @ResponseBody
        public AjaxResult addArticleReadCount(@RequestBody int articleId) { //添加文章阅读次数
            System.out.println("文章ID");
            System.out.println(articleId);
            return articleService.addArticleReadCount(articleId);
    }
    @RequestMapping(value = "/article/likeCount/add")
    @ResponseBody
    public AjaxResult addArticleLikeCount(@RequestBody LikeArticle likeArticle) { //添加文章阅读次数
        System.out.println("喜欢文章ID");
        System.out.println(likeArticle);
        return articleService.addArticleLikeCount(likeArticle);
    }
    @GetMapping(value = "/article/like")
    @ResponseBody
    public AjaxResult articleIsLike(@RequestParam int userId,int articleId) { //用户是否喜欢过该文章
        System.out.println("喜欢文章ID");
        System.out.println(articleId);
        return articleService.articleIsLike(userId,articleId);
    }
    @GetMapping(value = "/article/next")
    @ResponseBody
    public AjaxResult nextArticle(@RequestParam int articleId) { //下一篇文章
        System.out.println("下一篇文章Id");
        System.out.println(articleId);
        return articleService.nextArticle(articleId);
    }
}
